package com.ermax.aircond.common.web.bean;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.ermax.aircond.common.domain.ReadMachineData;
import com.ermax.aircond.common.service.ReadMachineDataService;

@Component
@Scope("request")
public class MenuBean implements java.io.Serializable{	
	
	@Resource(name="readMachineDataService")
	private ReadMachineDataService readMachineDataService;
	
	private static final long serialVersionUID = 1L;

	public String doBuildingMaintain(){
		return "pages/maintain/building";
	}
	
	public String doUserGroupMaintain(){
		return "pages/maintain/usergroup";
	}
	
	public String isErrorSignal() {
		
		List<ReadMachineData> readMachineDataList = readMachineDataService.getErrorNidData("E3");
		
		if (readMachineDataList.size() > 0) {
			
			StringBuilder nidStr = new StringBuilder();
			
			for(ReadMachineData readMachineData:readMachineDataList) {
				nidStr.append(readMachineData.getNid() + ",");
			}
			nidStr.substring(0, nidStr.length());
			return nidStr.toString();
			
		} else {
			return null;
		}
		
	}
	
}
